<div class="fshmeAdminBox">
<center>
<h3 class="adminTtl">Admin Login</h3>
	<p class="AdusrNm"><span class="Adcmn">UserName:</span><input type="text" id="adminUsername" name="adminUsername"/></p><span style="color:red" id="erroradminUsername"></span>
	<p class="Adpswrd"><span class="Adcmn">Password:</span><input type="password" id="adminPassword" name="adminPassword"/></p><span style="color:red" id="erroradminPassword"></span>
	<p class="AdLgn"><input type="button" onclick="validateadminLogin()" value="Login"/></p>
	<p style="color:red"><a href="/users/forgetpassword">Forgot password</a></p>
	<p style="color:red" id="loginFailed"></p>
	
</center>

</div>
<script>
$('#adminPassword').keypress(function(e){
		if( e.keyCode == 13 ){
			var flag=true;	
			if($('#adminUsername').val()==""){		
				$('#erroradminUsername').html('*User Name Required');
				flag=false;
			}else{
				$('#erroradminUsername').html('');
			}
			if($('#adminPassword').val()==""){
				$('#erroradminPassword').html('*Password Required');
				flag=false;
			}else{
				$('#erroradminPassword').html('');
			}
			if(flag==false){ 
				return false;
			}else{ 
				var userEmail=$('#adminUsername').val();
				var userPassword=$('#adminPassword').val();
				$.ajax({
					type:'POST',
					url:   '/users/login',
					data:{userEmail:userEmail,userPassword:userPassword},
					success: function(data){
						if(data.output=='success'){
							$('#loginFailed').html('');
								window.location='/admin/index';
						}else{
							$('#loginFailed').html('*Please Enter Valid Username And Password!');
						}
					}
				});
			}	
		}
	});
	function validateadminLogin(){
		var flag=true;	
			if($('#adminUsername').val()==""){		
				$('#erroradminUsername').html('*User Name Required');
				flag=false;
			}else{
				$('#erroradminUsername').html('');
			}
			if($('#adminPassword').val()==""){
				$('#erroradminPassword').html('*Password Required');
				flag=false;
			}else{
				$('#erroradminPassword').html('');
			}
			if(flag==false){ 
				return false;
			}else{ 
				var userEmail=$('#adminUsername').val();
				var userPassword=$('#adminPassword').val();
				$.ajax({
					type:'POST',
					url:   '/users/login',
					data:{userEmail:userEmail,userPassword:userPassword},
					success: function(data){
						if(data.output=='success'){
							$('#loginFailed').html('');
								window.location='/admin/index';
						}else{
							$('#loginFailed').html('*Please Enter Valid Username And Password!');
						}
					}
				});
			}	
		}
</script>